<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>修改密码</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no" />
	<meta http-equiv="Access-Control-Allow-Origin" content="*">
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<link rel="stylesheet" href="../css/base.css" />
	<link rel="stylesheet" href="../css/forgetPaymentPassword.css" />
	<style>
		.newPhone{
		width: 100%;
		height: 0.4rem;
		line-height: 0.4rem;
		text-indent: 0.1rem;
		border: none;
		outline:none;
	}
	.set_password_btn{
		border: none;
		outline: none;
	}
	</style>
</head>

<body>
	<div class="header">
		<a href="javascript:history.back(-1)"><img src="../img/g_next.png" alt="" /></a>
		修改密码
	</div>
	<div style="height: 0.44rem;"></div>
	<div class="forgetPaymentPassword_main">
		<p class="tishi">输入原密码</p>
		<ul class="set_zhifupassword_main">
			<input type="password" class="newPhone old-password" placeholder="请输入原密码" />
			<p class="tishi">输入新密码</p>
			<input type="password" class="newPhone new-password" placeholder="请输入新密码" />
		</ul>
	</div>
	<input type="button" value="提交" class="set_password_btn" />
</body>
<script src="../js/jquery-2.2.3.min.js"></script>
<script type="text/javascript" src="../js/rem.js"></script>
<script src="../js/common.js"></script>
<script>
	$('.set_password_btn').click(function () {
		var oldPassword = $('.old-password').val();
		var newPassword = $('.new-password').val();
		if (!(/^[\d_a-zA-Z]{6,12}$/.test(newPassword))) {
			alert('密码只能是6到12位数字、字母、下划线组成')
		} else {
			$.ajax({
				url: SURL + '/api/xlsUser/updatePassword',
				type: 'post',
				data: {
					userid: localStorage.getItem('userId'),
					oldPassword: oldPassword,
					newPassword: newPassword
				},
				dataType: 'json',
				success: res => {
					if (res.status == 1){
						location.href='set.html'
					}else{
						alert(res.msg);
					}
				},
				error: res => {
					alert(res.msg);
				}
			})
		}
	})
</script>

</html>
